import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:znmm/config/app_color.dart';

import 'auto_text_dialog.dart';

//自动生成
class AutoTempBtn extends StatefulWidget {
  const AutoTempBtn({super.key});

  @override
  State<AutoTempBtn> createState() => _AutoTempBtnState();
}

class _AutoTempBtnState extends State<AutoTempBtn> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () async {
        ///自动生成弹窗

        Get.dialog(
          const AutoTextDialog(),
          barrierDismissible: true,
        );
      },
      child: const GptTextButton(
        text: '自动生成',
      ),
    );
  }
}

/////////
class GptTextButton extends StatelessWidget {
  const GptTextButton({
    super.key,
    this.text,
  });
  final String? text;

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left: 10.w),
      padding: EdgeInsets.symmetric(horizontal: 5.w, vertical: 2.h),
      decoration: BoxDecoration(
        color: AppColor.blue396EC6,
        borderRadius: BorderRadius.circular(5),
      ),
      child: Text(
        text!,
        style: TextStyle(
          fontSize: 12.sp,
          color: AppColor.white,
        ),
      ),
    );
  }
}

///生成弹窗按钮
class GptButton extends StatelessWidget {
  const GptButton({
    super.key,
    this.onTap,
    this.text,
    this.color,
    required this.isLeft,
  });

  final GestureTapCallback? onTap;
  final String? text;
  final Color? color;
  final bool isLeft;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      //引用
      onTap: onTap,
      child: Container(
        width: Get.width * 0.4,
        height: 40.h,
        alignment: Alignment.center,
        decoration: BoxDecoration(
          color: color,
          borderRadius: isLeft
              ? BorderRadius.only(
                  bottomLeft: Radius.circular(5.r),
                )
              : BorderRadius.only(
                  bottomRight: Radius.circular(5.r),
                ),
        ),
        child: Text(
          text!,
          style: TextStyle(
            fontSize: 14.sp,
            color: Colors.white,
          ),
        ),
      ),
    );
  }
}
